Skip to content

fix(aitools): non-zero exit when discover-schema has any failed table#5116

Open
jamesbroadhead wants to merge 1 commit intomainfrom
jb/aitools-discover-schema-exit-code
Open

fix(aitools): non-zero exit when discover-schema has any failed table#5116
jamesbroadhead wants to merge 1 commit intomainfrom
jb/aitools-discover-schema-exit-code

Conversation

@jamesbroadhead
Copy link
Copy Markdown

Summary

databricks aitools tools discover-schema TABLE... rendered per-table failures into stdout but always returned nil from RunE. Even when every table failed, the process exited 0, so scripts and CI couldn't detect failure without grepping output for "Error discovering " — exactly the kind of err.Error() string-matching the repo's style guide forbids.

Extract the loop into runDiscoverSchemas which returns (output, anyFailed). RunE prints the output and returns root.ErrAlreadyPrinted when anyFailed is true so cobra produces a non-zero exit without re-printing the per-table errors. Behavior preserved: one bad table still doesn't abort the others.

Spotted via multi-model code review on #4917 (GPT 5.4). Pre-existing in #5097, not introduced by #4917 — sending as a separate small fix per the "keep PRs focused" rule.

Test plan

  • go test ./experimental/aitools/cmd/ (new tests: TestRunDiscoverSchemasFlagsTableFailureForExitCode, TestRunDiscoverSchemasAllSucceedReturnsFalse).
  • Manual: databricks aitools tools discover-schema doesnt.exist.foo; echo $? should now print 1.
  • Manual: a successful run still prints 0.

This pull request and its description were written by Isaac.

Per-table failures were rendered into stdout but the command still
returned nil from RunE, so the process exited 0 even when every
table failed. Scripts and CI couldn't detect failure without parsing
output for "Error discovering ...", which is exactly the kind of
err.Error() string-matching the repo's style guide forbids.

Extract the loop into runDiscoverSchemas which returns (output, anyFailed).
RunE prints the output and returns root.ErrAlreadyPrinted when anyFailed
is true so cobra produces a non-zero exit without re-printing the errors.

Behavior preserved: per-table failures still don't abort the others.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown

Waiting for approval

Based on git history, these people are best suited to review:

  • @simonfaltum -- recent work in experimental/aitools/cmd/
  • @arsenyinfo -- recent work in experimental/aitools/cmd/

Eligible reviewers: @MarioCadenas, @Shridhad, @atilafassina, @calvarjorge, @ditadi, @fjakobs, @igrekun, @keugenek, @lennartkats-db, @pffigueiredo, @pkosiec

Suggestions based on git history. See OWNERS for ownership rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant